bprint(" IS CAMPING AT "); //#Harlequin# 'is sniping at' is ambiguous -- sounds like they're shooting at something
bprint(campitem.message);
}
else
{
bprint(" IS CAMPING AT THE ");
bprint(campitem.CAMPPOS);
}
bprint("!\n");
//#Harlequin# Take away 2 frags
camper.frags = camper.frags - 2;
};
//#Harlequin# GetLongDistance determines the distance at which items
//will issue warnings if they have an unbroken line-of-sight to the
//player. On levels with lots of open spaces, for example e1m8, this
//value should be set lower than the default 800, to avoid detecting
//innocent (well, non-camping anyway) players. To give you an idea
//of how far 800 units is, it's about the distance from the rocket
//launcher of e1m1 to the L-bend in the catwalk leading there.
//Setting longdist to 1 in a map disables AntiCamper for that map.
//Do NOT set it to zero or you'll slow down the server.
float() GetLongDistance =
{
local float dist;
//#Harlequin# Defaults to 800
dist = 800;
//#Harlequin# Put map names and LOS-distances here, in the following format:
if (world.model == "maps/e1m8.bsp")
dist = 400;
//#Harlequin# Keep this as the last line of the function
return dist;
};
//#Harlequin# GetShortDistance is the distance at which items will
//see players if they do *not* have line-of-sight. This is necessary
//to prevent people from ducking around corners to defeat the mod.
//On small levels, where it's easy to be "seen" through walls by
//camper-sensitive items, set this lower than the default 250. On
//camper-heavy maps with out-of-the-way weapons, setting this value
//higher is useful.
float() GetShortDistance =
{
local float dist;
//#Harlequin# Defaults to 250
dist = 250;
//#Harlequin# Put map names and no-LOS distances here. Note that it
//is possible to change both longdist and shortdist on a single map,
//but shortdist will never be longer than longdist.
if (world.model == "maps/e1m8.bsp")
dist = 200;
//#Harlequin# Keep this as the last line of the function
return dist;
};
//#Harlequin# GetThinkTimes returns an average length between camper
//checks, in seconds, for every item on the level. It will actually
//vary between (thinktime - 0.5) and (thinktime + 0.5) sec.
float() GetThinkTimes =
{
local float ttimes;
//#Harlequin# Defaults to 8
ttimes = 8;
//#Harlequin# Add your own map names and think times below
if (world.model == "maps/e1m8.bsp")
ttimes = 6;
//#Harlequin# Leave the following line as the last one
return ttimes;
};
//#Harlequin# ItemFindCampers is the heart of the mod. It checks
//a sphere of radius 'longdist' around itself, and if it finds any
//players in its line of sight it "tags" them (it also tags players
//that are not within LOS, but are less than 'shortdist' units away).
//If they're still there after one think time (~8 seconds), it warns
//them. If they're still there after two think times, it kills them.
//Thus from the time someone starts camping, the average total time
//for an item to see them, warn them, and nuke them is 20 seconds.
void() ItemFindCampers =
{
local entity head;
//#Harlequin# Get 'longdist' LOS warning distance & 'shortdist' no-LOS warning distance, map-dependent
if (!longdist)
longdist = GetLongDistance();
if (!shortdist)
shortdist = GetShortDistance();
//#Harlequin# Get think times
if (!thinktimes)
thinktimes = GetThinkTimes();
//#Harlequin# Think times are somewhat random so it's harder to second-guess, also improves speed
self.think = ItemFindCampers;
self.nextthink = time + (thinktimes - 0.5) + random();
//#Harlequin# Respawn item if it's time
if (self.RESPAWN_TIME && (self.RESPAWN_TIME <= time))
{
SUB_regen();
self.RESPAWN_TIME = 0;
}
//#Harlequin# Looks for players within 'longdist' units of itself
head = findradius(self.origin, longdist);
while (head)
{
//#Harlequin# Don't pick on non-players, dead players, or camperkilled players. The CAMPER_TIME part is there to prevent items from cancelling each other out.
if ((head.classname == "player") && (!(head.deadflag >= DEAD_DEAD)) && (head.pausetime < time + 100) && (head.CAMPER_TIME < time + (thinktimes / 2)))
{
//#Harlequin# Checks for line-of-sight, or less than 'shortdist' distance -- checks origin + '0 0 20' because origins are at ground level